#pragma once

template<size_t N>
class Bitset
{
public:
	Bitset()
	{
		_bs.resize(N / 8 + 1, 0);
	}

	void set(size_t n)
	{
		size_t i = n / 8;
		size_t j = n % 8;
		_bs[i] |= (1 << j);
	}

	void reset(size_t n)
	{
		size_t i = n / 8;
		size_t j = n % 8;
		_bs[i] &= (~(1 << j));
	}

	bool test(size_t n)
	{
		size_t i = n / 8;
		size_t j = n % 8;
		return _bs[i] & (1 << j);
	}

private:
	vector<char> _bs;
};

void test_bitset1()
{
	int arr[] = { 1,45,76,2,8,65,32,84,15 };
	Bitset<100> bs;
	for (auto a : arr)
	{
		bs.set(a);
	}

	bs.reset(15);
	cout << bs.test(76) << endl;
}

void test_bitset2()
{
	//bitset<100> bs1;
	//bitset<-1> bs2;
	Bitset<0xffffffff> bs2;

	bs2.set(10);
	bs2.set(10000);
	bs2.set(8888);

	cout << bs2.test(10) << endl;
	cout << bs2.test(10000) << endl;
	cout << bs2.test(8888) << endl;
	cout << bs2.test(8887) << endl;
	cout << bs2.test(9999) << endl << endl;

	bs2.reset(8888);
	bs2.set(8887);

	cout << bs2.test(10) << endl;
	cout << bs2.test(10000) << endl;
	cout << bs2.test(8888) << endl;
	cout << bs2.test(8887) << endl;
	cout << bs2.test(9999) << endl;
}